package com.sky.mapper.admin;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Dish;
import com.sky.pojo.DishFlavor;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {

    Page<Dish> findDishByPage(DishPageQueryDTO dishPageQueryDTO);

    @AutoFill(OperationType.INSERT)
    int addDish(Dish dish);

    DishVO findDishById(Long id);

    int deleteDish(@Param("id") List<Long> ids);

    int deleteDishFlavor(@Param("id") List<Long> ids);

    int selectCountByIdAndStatus(@Param("id") List<Long> ids,@Param("status") Integer status);

    @Update("update dish set status = #{status} where id = #{id}")
    int updateStatus(@Param("status") Integer status, @Param("id") Long id);


    int updateDish(Dish dish);

    int addNewFlavor(List<DishFlavor> flavors);

    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> findByCategoryId(Long categoryId);
}
